<template>
    <div class="distribution-funds">
        <c-title text="慈善基金"></c-title>
        <img  v-if="top_thumb" :src="top_thumb" @click="goto" />
        <div class="box">
            <div class="head-box">
                <div class="title">慈善基金</div>
                <div class="price">{{ amount }}</div>
            </div>
            <van-tabs v-model="active" title-active-color="#FF8924">
                <van-tab title="慈善基金来源及使用明细">
                    <van-cell v-for="item in list" :key="item.id" title-style="text-align:left">
                        <span slot="title">ID：{{ item.id }}</span>
                        <span slot="label" class="label">备注：{{ item.note }}</span>
                        <div slot="default" class="right-value">
                            <span>{{item.change_amount}}</span>
                            <span class="label">{{ item.created_at }}</span>
                        </div>
                    </van-cell>
                </van-tab>
            </van-tabs>
        </div>

        <div style="height: 2.4063rem;"></div>
    </div>
</template>

<script>
import {scrollMixin} from "../../../utils/mixin";
export default {
    mixins:[scrollMixin],
    data() {
        return {
            active: 0,
            page:1,
            list:[],
            total_page:1,
            isLoadMore: true,

            top_thumb:"",
            web_jump:"",
            amount:"",
        };
    },
    activated(){
        this.isLoadMore = true;
        this.getData();
    },
    methods: {
        goto(){
            if(this.web_jump){
                window.location.href = this.web_jump;
            }
        },
        getData(page=1){
            $http.get("plugin.charity-money.frontend.index.index",{page},"").then(res=>{
                this.isLoadMore = true;
                if(res.result!==1){
                    return this.$toast(res.msg);
                }
                let data = res.data;
                this.top_thumb = data.top_thumb;
                this.web_jump = data.web_jump;
                this.amount = data.amount;
                this.list = (data.list.current_page==1)?data.list.data:(this.list.concat(data.list.data));
                this.page = data.list.current_page;
                this.total_page = data.list.last_page;
            })
        },
        getMoreData(){
            this.isLoadMore = false;
            if(this.page>=this.total_page){
                return;
            }
            let page = this.page  + 1;
            this.getData(page);
        },
    }
};
</script>

<style scoped lang="scss">
::v-deep .van-tabs__line{
    background-color: #FF8924;
}
.distribution-funds {
    img {
        margin: 0;
        width: 100%;
    }

    .right-value {
        display: flex;
        flex-direction: column;
        font-size: 0.875rem;
        font-weight: 500;
        color: #3B3B4A;
        justify-content: space-between;
        height: 100%;
    }

    .label {
        height: 0.75rem;
        font-size: 0.75rem;
        font-weight: 400;
        line-height: .75rem;
        color: #AAAAB3;
    }

    .title {
        font-size: 0.875rem;
        color: #3B3B4A;
    }

    .price {
        color: #F15353;
        font-size: 1.5rem;
        margin-top: 0.3125rem;
    }

    .head-box {
        margin: .75rem 0.75rem 0 ;
        background: rgba(255, 238, 224, 0.39);
        border-radius: 10px;
        padding: 1rem;
    }

    .box {
        margin: 0.75rem;
        background: #fff;
        border-radius: 10px;
        overflow: hidden;
    }
}
</style>
